package lsy.redis001.lsyredis001.common.response;

import lombok.Data;
import lsy.redis001.lsyredis001.common.constant.Constant;

/**
 * @Description 封装的返回结果
 * @Author lsy
 * @Date 下午 4:05 2020/3/17 0017
 * @Param
 * @return
 **/
@Data
public class RespEntity<T> {
    private Integer resultCode;
    private String message;
    private T data;

    RespEntity(){}

    RespEntity(T data){
        this.resultCode = Constant.HTTP_SUCCESS_CODE;
        this.data = data;
    }

    public static <T> RespEntity<T> success(T data){
        return new RespEntity<T>(data);
    }

    public static <T> RespEntity<T> error(Integer code, String message){
        RespEntity<T> respEntity = new RespEntity<>();
        respEntity.setResultCode(code);
        respEntity.setMessage(message);
        return respEntity;
    }
}
